package com.yuqing.sentimentapp.home.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.TextView;

import com.linkface.common.adaper.CommonRecycleAdapter;
import com.linkface.common.adaper.CommonViewHolder;
import com.yuqing.sentimentapp.R;
import com.yuqing.sentimentapp.home.bean.EarlyWarningDataBean;
import com.yuqing.sentimentapp.utils.GlideUtil;

import java.util.List;

/**
 * Created by shenhe on 2018/9/19.
 */

public class EarlyWarningAdapter extends CommonRecycleAdapter<EarlyWarningDataBean.DataBean>{
    private CommonViewHolder.onItemCommonClickListener commonClickListener;
    private Context mContext;

    public EarlyWarningAdapter(Context context, List<EarlyWarningDataBean.DataBean> dataList) {
        super(context, dataList, R.layout.fragment_early_warning_item);
        this.mContext = context;
    }

    public EarlyWarningAdapter(Context context, List<EarlyWarningDataBean.DataBean> dataList, CommonViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, R.layout.fragment_early_warning_item);
        this.mContext = context;
        this.commonClickListener = commonClickListener;
    }

    @Override
    public void bindData(final CommonViewHolder holder, final EarlyWarningDataBean.DataBean data) {
        String isRead = data.getIsRead();
        if (!TextUtils.isEmpty(isRead) && TextUtils.equals("1", isRead)) {
            ((TextView) holder.getView(R.id.tv_title)).setTextColor(mContext.getResources().getColor(R.color.color_aaaaaa));
        } else {
            ((TextView) holder.getView(R.id.tv_title)).setTextColor(mContext.getResources().getColor(R.color.color_333333));
        }
        holder.setText(R.id.tv_title, data.getTitle())
                .setText(R.id.tv_date, data.getCreateAt());
        GlideUtil.getImageByGif(mContext, data.getIcon(), holder.getView(R.id.iv_pic));
        holder.setCommonClickListener(commonClickListener);
    }
}
